/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.beans.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Mariam Soumaré
 */
@Entity
@Table(name = "commandes")
@NamedQueries({
    @NamedQuery(name = "Commandes.findAll", query = "SELECT c FROM Commandes c"),
    @NamedQuery(name = "Commandes.findById", query = "SELECT c FROM Commandes c WHERE c.id = :id"),
    @NamedQuery(name = "Commandes.findByDateValidation", query = "SELECT c FROM Commandes c WHERE c.dateValidation = :dateValidation"),
    @NamedQuery(name = "Commandes.findByIdClient", query = "SELECT c FROM Commandes c WHERE c.idClient = :idClient")})
public class Commandes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @Column(name = "DATE_VALIDATION")
    @Temporal(TemporalType.DATE)
    private Date dateValidation;
    @Basic(optional = false)
    @Column(name = "ID_CLIENT")
    private long idClient;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "commandes")
    private List<Achats> achatsList;

    public Commandes() {
    }

    public Commandes(Long id) {
        this.id = id;
    }

    public Commandes(Date dateValidation, long idClient) {
       
        this.dateValidation = dateValidation;
        this.idClient = idClient;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDateValidation() {
        return dateValidation;
    }

    public void setDateValidation(Date dateValidation) {
        this.dateValidation = dateValidation;
    }

    public long getIdClient() {
        return idClient;
    }

    public void setIdClient(long idClient) {
        this.idClient = idClient;
    }

    public List<Achats> getAchatsList() {
        return achatsList;
    }

    public void setAchatsList(List<Achats> achatsList) {
        this.achatsList = achatsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commandes)) {
            return false;
        }
        Commandes other = (Commandes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.beans.entity.Commandes[id=" + id + "]";
    }

}
